namespace Wilco.SyntaxHighlighting.Engine.Node.Occurrence
{
    /// <summary>
    /// Represents an occurrence.
    /// </summary>
    public struct Occurrence
    {
        private int start;
        private int length;
        private readonly INode node;

        /// <summary>
        /// Gets or sets the start index of the occurrence.
        /// </summary>
        public int Start
        {
            get
            {
                return start;
            }
            set
            {
                if (value != start)
                {
                    start = value;
                }
            }
        }

        /// <summary>
        /// Gets or sets the length of the occurrence.
        /// </summary>
        public int Length
        {
            get
            {
                return length;
            }
            set
            {
                if (value != length)
                {
                    length = value;
                }
            }
        }

        /// <summary>
        /// Gets the node the occurrence represents.
        /// </summary>
        public INode Node
        {
            get
            {
                return node;
            }
        }
		
        /// <summary>
        /// Initializes a new instance of a <see cref="Occurrence"/> struct.
        /// </summary>
        /// <param name="start">The start index of the occurrence.</param>
        /// <param name="length">The length of the occurrence.</param>
        /// <param name="node">The node the occurrence represents.</param>
        public Occurrence(int start, int length, INode node)
        {
            this.start = start;
            this.length = length;
            this.node = node;
        }
    }
}